package Exe;

import java.util.TreeMap;

public class Exe2Count {
    public static void main(String[] args) {
        String s="abbbaacddcddcdcbabacd";
        TreeMap<Character,Integer> map=new TreeMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c=s.charAt(i);

            if(map.containsKey(c)){
                int count=map.get(c);
                count++;
                map.put(c,count);
            }else{
                map.put(c,1);
            }
        }

        map.forEach((s1,s2)-> System.out.println(s1+" "+s2));

    }
}
